package com.py.credit.controller;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.BigScreenService;
import com.py.credit.service.RemoteBaseService;
import com.py.framework.core.annotation.IgnoreAuthority;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

/**
 * @author ·︿·   LXW$
 * @title: BigScreenServiceController
 * @projectName credit-framework-common
 * @description:
 * @date 2020/7/2820:27
 */

@RestController
@RequestMapping(value = "/bsigScreenServiceController")
public class BigScreenServiceController {

    @Autowired
    private BigScreenService bigScreenService;
    @Autowired
    private RemoteBaseService remoteBaseService;

    /**
     * 天地图调用字典值
     */
    private static String TDMAP = "TDMAP";
    /**
     * 天地图调用URL
     */
    private static String TDURL = "URL";
    /**
     * 天地图调用KEY
     */
    private static String TDKEY = "KEY";

    /**
     * @Description
     * @param
     * @Return com.py.credit.common.rest.RestServiceResult<java.util.Map<java.lang.String,java.lang.Object>>
     * @Exception
     * @Version 2.6.3 yn
    　  * @throws
    　　* @author   ˇ︿ˇ  LXW$
    　　* @date 2020/7/29 16:39
    　　*/
    @IgnoreAuthority
    @RequestMapping(value = "/allCountAndFrCount.json")
    public RestServiceResult<Map<String,Object>> tendencyAnalyse() {
        return new RestServiceResult<Map<String,Object>>(bigScreenService.selectBatchSCount());
    }

    /**
        * @Description
         * @param null
        * @Return 
        * @Exception 获取经纬度
        * @Version 2.6.3 yn
    　  * @throws
    　　* @author   ˇ︿ˇ  LXW$
    　　* @date 2020/7/29 16:42 
    　　*/
    @IgnoreAuthority
    @RequestMapping(value = "/getFrolonAndlat.json")
    public RestServiceResult<Object> getFrolonAndlat() {
        try {
            String mapUrl = remoteBaseService.getDictByDtlKey(TDMAP, TDURL).getData().getDtlValue();
            String mapKey = remoteBaseService.getDictByDtlKey(TDMAP, TDKEY).getData().getDtlValue();
            bigScreenService.getFrolonAndlat(mapUrl, mapKey);
            return new RestServiceResult<>();
        } catch (Exception e) {
            RestServiceResult<Object> result = new RestServiceResult<Object>();
            result.setCode(RestServiceResult.CODE_UNKNOW);
            result.setMsg("经纬度更新定时任务异常！ERROR:" + e.getMessage());
            ExceptionLogger.error("经纬度更新定时任务DataRemindController#taskRemind", "任务提醒定时任务异常！ERROR:" + e.getMessage(), e);
            return result;
        }
    }
}
